package com.ldc.message.adapter

import androidx.recyclerview.widget.RecyclerView
import com.ldc.commonlibs.listener.OnRowListener
import com.ldc.commonres.common.BaseRvAdapter
import com.ldc.commonres.common.BaseRvViewHolder
import com.ldc.commonres.uts.TagUts
import com.ldc.message.R
import com.ldc.message.model.MessageModel
import com.ldc.commonres.model.BaseTagModel

class MessageListAdapter :
    BaseRvAdapter<MessageModel>(R.layout.message_layout_view_item_message_list) {
    private var itemClick: OnRowListener<MessageModel>? = null
    fun addOnRowListener(itemClick: OnRowListener<MessageModel>?) {
        this.itemClick = itemClick
    }

    override fun convertTo(holder: BaseRvViewHolder, data: MessageModel, position: Int) {
        val rv: RecyclerView = holder.findView(R.id.rv_tag) as RecyclerView
        holder.addOnRowListener(holder.itemView, data, itemClick)
        holder.setText(R.id.tv_title, data.title)
        holder.setText(R.id.tv_form_user, "${data.fromUser} 回复了~")
        holder.setText(R.id.tv_message, data.message)
        TagUts.tagList(arrayListOf(BaseTagModel(data.tag, "")), rv)
        holder.setText(R.id.tv_date, data.niceDate)
    }
}